package com.push.web.controller;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.push.web.domain.BizArticle;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.push.common.annotation.Log;
import com.push.common.core.controller.BaseController;
import com.push.common.core.domain.AjaxResult;
import com.push.common.enums.BusinessType;
import com.push.web.domain.BizDailyInfo;
import com.push.web.service.IBizDailyInfoService;
import com.push.common.utils.poi.ExcelUtil;
import com.push.common.core.page.TableDataInfo;

/**
 * 每日监测信息Controller
 *
 * @author yanxi
 * @date 2024-02-27
 */
@RestController
@RequestMapping("/information/dailyMonitoring")
public class BizDailyInfoController extends BaseController
{
    @Autowired
    private IBizDailyInfoService bizDailyInfoService;

    /**
     * 查询每日监测信息列表
     */
    @PreAuthorize("@ss.hasPermi('information:dailyMonitoring:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDailyInfo bizDailyInfo)
    {
        startPage();
        List<BizDailyInfo> list = bizDailyInfoService.selectBizDailyInfoList(bizDailyInfo);
        return getDataTable(list);
    }

    /**
     * 导出每日监测信息列表
     */
    @PreAuthorize("@ss.hasPermi('information:dailyMonitoring:export')")
    @Log(title = "每日监测信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizDailyInfo bizDailyInfo)
    {
        List<BizDailyInfo> list = bizDailyInfoService.selectBizDailyInfoList(bizDailyInfo);
        ExcelUtil<BizDailyInfo> util = new ExcelUtil<BizDailyInfo>(BizDailyInfo.class);
        return util.exportExcel(list, "每日监测信息数据");
    }

    /**
     * 导出信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('information:dailyMonitoring:export')")
    @Log(title = "信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public AjaxResult export(@RequestBody String ids)
    {
        List<Long> aids= Arrays.stream(ids.split(",")).map(s->Long.parseLong(s.trim())).collect(Collectors.toList());
        List<BizDailyInfo> list = bizDailyInfoService.selectBizDailyInfoByIds(aids);
        ExcelUtil<BizDailyInfo> util = new ExcelUtil<BizDailyInfo>(BizDailyInfo.class);
        return util.exportExcel(list, "信息数据");
    }

    /**
     * 获取每日监测信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('information:dailyMonitoring:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizDailyInfoService.selectBizDailyInfoById(id));
    }

    /**
     * 新增每日监测信息
     */
    @PreAuthorize("@ss.hasPermi('information:dailyMonitoring:add')")
    @Log(title = "每日监测信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizDailyInfo bizDailyInfo)
    {
        return toAjax(bizDailyInfoService.insertBizDailyInfo(bizDailyInfo));
    }

    /**
     * 修改每日监测信息
     */
    @PreAuthorize("@ss.hasPermi('information:dailyMonitoring:edit')")
    @Log(title = "每日监测信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizDailyInfo bizDailyInfo)
    {
        return toAjax(bizDailyInfoService.updateBizDailyInfo(bizDailyInfo));
    }

    /**
     * 删除每日监测信息
     */
    @PreAuthorize("@ss.hasPermi('information:dailyMonitoring:remove')")
    @Log(title = "每日监测信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizDailyInfoService.deleteBizDailyInfoByIds(ids));
    }
}
